import { list, exportList, exportDormAllocationInfolist, getfloorInfoById, addInfo, putInfoById, delInfoById, deleteUseBedByRoomIds, getDormAllocationInfolist, getUserBedList, getuserBedLog,updateBedInfo } from '@/api/apartment/roomBedlist'

const data = {
    state: {
        list: [],
        allocationInfolist: [],
        userBedList: [],
        userBedLog: []
    },

    mutations: {
        SET_list: (state, list) => {
            state.list = list
        },
        SET_allocationInfolist: (state, list) => {
            state.allocationInfolist = list
        },
        SET_userBedList: (state, list) => {
            state.userBedList = list
        },
        SET_userBedLog: (state, list) => {
            state.userBedLog = list
        },

    },

    actions: {
        // 获取列表
        async getTable({ commit }, params) {
            const { rows, code } = await list(params);
            commit("SET_list", rows)
        },

        async exportList({ commit }, params) {
            const { data, code } = await exportList(params);
            return { data, code }
        },

        async getfloorInfoById({ commit }, params) {
            const { data, code } = await getfloorInfoById(params);
            return { data, code }
        },

        async addInfo({ commit }, params) {
            const { data, code } = await addInfo(params);
            return { data, code }
        },

        // async putInfoById({ commit }, params) {
        //     const { data, code } = await putInfoById(params);
        //     return { data, code }
        // },

        async delInfoById({ commit }, params) {
            const { data, code } = await delInfoById(params);
            return { data, code }
        },

        async deleteUseBedByRoomIds({ commit }, params) {
            const { data, code } = await deleteUseBedByRoomIds(params);
            return { data, code }
        },

        async getDormAllocationInfolist({ commit }, params) {
            const { rows, code, total } = await getDormAllocationInfolist(params);
            commit("SET_allocationInfolist", rows)
            return { data, code, total }
        },

        async getUserBedList({ commit }, params) {
            const { rows, code } = await getUserBedList(params);
            commit("SET_userBedList", rows)
            return { data, code }
        },

        async getuserBedLog({ commit }, params) {
            const { rows, code, total } = await getuserBedLog(params);
            commit("SET_userBedLog", rows)
            return { data, code, total }
        },

        async updateBedInfo({ commit }, params) {
            const { rows, code } = await updateBedInfo(params);
            return { data, code }
        },

        async exportDormAllocationInfolist({ commit }, params) {
            const data = await exportDormAllocationInfolist(params);
            return data
        },

    },
    namespaced: true,
}

export default data
